#!/bin/bash

yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
				  
yum install -y yum-utils
yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

# http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 阿里云镜像站

yum install -y docker-ce docker-ce-cli containerd.io

if [[ -f /etc/docker/daemon.json  ]] ; then
	cp /etc/docker/daemon.json /etc/docker/daemon.json.bak
fi

echo -e '
{

"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]

}
' >> /etc/docker/daemon.json

rm -rf /etc/yum.repos.d/docker-ce.repo
systemctl daemon-reload 
systemctl enable docker
systemctl restart docker
docker version